function debounce(fn, delay) {
    let time = null;
    return function () {
        clearTimeout(time);
        time = setTimeout(() => {
            fn();
        }, dalay);
    }
}